class StartGameScene extends eui.Component implements eui.UIComponent {
	public constructor() {
		super();
	}

	protected partAdded(partName: string, instance: any): void {
		super.partAdded(partName, instance);
	}


	protected childrenCreated(): void {
		super.childrenCreated();
		this.init();
		
	}

	public btn_start: eui.Label;
	public ani2: eui.Image;
	public ani1: eui.Image;
	public ani3: eui.Image;

	

	private init() {
		this.setAnc(this.ani1)
		this.setAnc(this.ani2)
		this.setAnc(this.ani3)
		
		this.addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
			SceneManager.Instance.switchScene(SceneManager.Instance.chooseMode);
		}, this);
		egret.Tween.get(this.btn_start, { loop: true }).to({ alpha: 0 }, 1000).to({ alpha: 1 }, 1000);
		let p1 = this.setAniRotaition();
		p1.then(()=>{
			egret.Tween.get(this.ani2, { loop: true }).to({ rotation: 30 }, 1000).to({ rotation: 0 }, 1000)
		}).then(()=>{ 
			egret.Tween.get(this.ani3, { loop: true }).to({ rotation: 30 }, 1000).to({ rotation: 0 }, 1000)
		})
		
	}
	private setAniRotaition(){
		return new Promise((resolve, reject)=>{
			egret.Tween.get(this.ani1, { loop: true }).to({ rotation: 30 }, 1000).to({ rotation: 0 }, 1000)
		})
	}
	private setAnc(obj:egret.DisplayObject){
		obj.anchorOffsetX = obj.width/2;
		obj.anchorOffsetY = obj.height/2;
		obj.x +=obj.width/2;
		obj.y +=obj.height/2; 
	}

}